package com.example.pages;
import static org.openqa.selenium.support.ui.ExpectedConditions.alertIsPresent;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

public class InternalPage extends AnyPage {
	
	@FindBy(xpath = "//nav//li[4]/a")
	public WebElement menuLogOutLink; 
	
	
	@FindBy(xpath = "//nav//li[2]/a")
	public WebElement menuProfileLink;
	
	@FindBy(xpath = "//nav//li[3]/a")
	public WebElement menuUserManagementLink;
	
	
	@FindBy(xpath = "//nav//li/a")
	public WebElement menuHomeLink;
	
	public boolean isOnThisPage() {
		return menuLogOutLink.isDisplayed();
}
	public void logOut() {
		//logout
		menuLogOutLink.click();
		wait_for().until(alertIsPresent()).accept();
			
			}
	
	@Override
	void tryToOpen() {
		MyPageFactory.getPage(driver, LoginPage.class).logInCorrectUser("admin", "admin");
	}
	
	public UserPage goToUserManagementPage() {
         //go to User Management Page
         menuUserManagementLink.click();
         return MyPageFactory.getPage(driver, UserPage.class);
     }
	
}